package me.suntao.javaio.server.bio;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * java 单线程阻塞式IO模式
 * Created by suntao on 2017/6/2.
 */
public class EchoServer {
  /**
   * 默认端口
   */
  private static final int DEFAULT_PORT = 28000;

  public static void main(String[] args) throws IOException, InterruptedException {
    ServerSocket serverSocket = new ServerSocket(DEFAULT_PORT);
    while (true) {
      Socket clientSocket = serverSocket.accept();
      DataInputStream inputStream = new DataInputStream(clientSocket.getInputStream());
      System.out.println("serverclient:"+Thread.currentThread().getName()+" clientmsg:" + inputStream.readUTF()+" donetime:"+System.currentTimeMillis());
      Thread.sleep(10);
    }
  }


}
